<template>
    <layout :config="navConfig">
        <template #default>
            <div class="login-logo">
                <img src="../assets/img/SD-01.png" style="width: 100px;height: 100px">
            </div>
            <div class="m-task-info-box">
                <div class="task-item_info" v-for="$item in taskData" :key="$item.id">
                    <p>
                       <span>交易金额</span>
                        <span v-if="$item.is_pid==1">{{100 *0.5*Math.pow(2,$item.type)}}$</span>
                        <span v-if="$item.is_pid==0">{{100 *0.25*Math.pow(2,$item.type)}}$</span>
                    </p>
                    <p>
                        <span>打款人ID</span>
                        <span>{{$item.payerId}}</span>
                    </p>
                    <p>
                        <span>打款人微信</span>
                        <span>{{$item.cwechatqrcode}}</span>
                    </p>
                    <p>
                        <span>打款人支付宝账户</span>
                        <span>{{$item.calypayqrcode}}</span>
                    </p>
                    <p>
                        <span>打款人手机号</span>
                        <span>{{$item.username}}</span>
                    </p>
                    <p>
                        <span>交易时间</span>
                        <span>{{$item.time}}</span>
                    </p>

                    <div class="buttons">
                        <button @click="tg($item.id)">通过</button>
                        <button @click="qx($item.id)">拒绝</button>
                    </div>
                    <div class="buttons" v-if="$item.is_pay==0">
                        <button>未打款</button>
                    </div>
                </div>
            </div>
        </template>
    </layout>
</template>

<script lang="ts">
    import {Component, Vue} from "vue-property-decorator";
    import {INavigation} from "@/types";
    import {Toast} from 'mand-mobile'

    @Component({
        name: "Matching",
        created: function () {
            this.type = this.$route.query.key;
            this.paymoney = this.$route.query.money / 100 * 10;
            let usera = JSON.parse(localStorage.getItem('users1'));


            Toast.loading("请求中...");

            this.$api.paylist({search_EQ_payuser: usera.username}).then(res => {
                Toast.hide();
                if (res.success == 200) {
                    this.taskData = res.data;

                    console.log(res.data);
                }
            }).catch(res => {

            })


        }
    })
    export default class extends Vue {
        navConfig: INavigation = {
            text: "匹配中"
        };
        tg(id) {

            this.$api.paysp({
                userpayid: id,
                issp: '1'
            }).then(res => {
                if (res.success == 200) {
                    Toast.info("请求成功！");
                    this.load();
                } else {
                    Toast.info(res.data.msg)

                }
            }).catch(res => {
                Toast.info("请求失败！");
            })

        };
        load(){
            Toast.loading("请求中...");
            let usera = JSON.parse(localStorage.getItem('users1'));

            this.$api.paylist({search_EQ_payuser: usera.username}).then(res => {
                Toast.hide();
                if (res.success == 200) {
                    this.taskData = res.data;
                    // this.formData_1.commit=usera.username;
                    console.log(res.data);
                }
            }).catch(res => {

            })
        };
        qx(id) {

            this.$api.paysp({
                userpayid: id,
                issp: '2'
            }).then(res => {
                if (res.success == 200) {
                    Toast.info("请求成功！");
                    this.load();
                } else {
                    Toast.info(res.data.msg)

                }
            }).catch(res => {
                Toast.info("请求失败！");
            })
        };

        taskData = [];
    }
</script>


<style lang="scss">
    @import "../assets/styles/matching.scss";
</style>
